package com.gzk.oeno.business.compare;

import java.util.Comparator;

import com.gzk.oeno.business.opinion.Opinion;

public class OpinionDateComparator implements Comparator<Opinion>{

	@Override
	public int compare(Opinion o1, Opinion o2) {
		if (o1 == null && o2 == null)
			return 0;
		if (o1 == null)
			return 1;
		if (o2 == null)
			return -1;
		
		int dateComp = o1.getDate().compareTo(o2.getDate());
		if (dateComp == 0){
			return -o1.getScore().compareTo(o2.getScore());
		}
		return -dateComp;
	}

}
